package br.ykhan.t5.ytools.menu.services;

import junit.framework.Assert;

import org.apache.tapestry5.ioc.Registry;
import org.apache.tapestry5.ioc.RegistryBuilder;
import org.apache.tapestry5.services.TapestryModule;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import br.ykhan.t5.ytools.menu.beans.SiteMenu;
import br.ykhan.t5.ytools.menu.utils.Utils;

/**
 * @see MenuSource
 */
public class MenuSourceTester
{
	private Registry registry;

	@Before
	public void setUp() throws Exception
	{
		RegistryBuilder registryBuilder = new RegistryBuilder();
		
		registryBuilder.add(TapestryModule.class);
		registryBuilder.add(MenuModule.class);
		
		registry = registryBuilder.build();
		
		registry.performRegistryStartup();
	}

	@After
	public void shutdown() throws Exception
	{
		registry.shutdown();
	}

	/**
	 * @see MenuSource#getMenus()
	 */
	@Test
	public void testGetMenus()
	{
		MenuSource menuSource = registry.getService(MenuSource.class);
		
		SiteMenu menu = menuSource.getMenu();
		
		// TODO: Melhorar esse Teste, com Mock ou algo similar
		Assert.assertTrue(!Utils.isEmptyMenu(menu));
	}

}
